//go:build bindgen
// +build bindgen

package model

import (
	"gitee.com/xuender/bindgen"
	"gitee.com/xuender/bindgen/_example/pb"
)

// BindToView bind to view.
func BindToView(view *pb.User, model *User) {
	panic(bindgen.Build())
}

func BindToViewIgnore(view *pb.User, model *User) {
	panic(bindgen.Build("Nick"))
}

// Bind UserModel.
func (p *User) Bind(view *pb.User) {
	panic(bindgen.Build())
}

func (p *User) NewView() *pb.User {
	view := &pb.User{}
	BindToView(view, p)

	return view
}

func NewView(model *User) *pb.User {
	view := &pb.User{}
	BindToView(view, model)

	return view
}

func NewModel(view *pb.User) *User {
	user := &User{}
	user.Bind(view)

	return user
}
